home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / TEXTFILE.SWG / 0005_LONGLINE.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  67 lines

  1. Program longline;
  2.  
  3. Var
  4.   LinePart: String;
  5.   InFile, OutFile: Text;
  6.   Index1, Index2: Word;
  7.   Result: Byte;
  8.  
  9. begin { First create a test File With lines longer than     }
  10.       { 255 caracters, this routine will generate lines in  }
  11.       { exess of 600 caracters. The last "EOLN" at the end  }
  12.       { is a visual aid to check that the Complete line has }
  13.       { been copied to the output File.                     }
  14.  
  15.   Assign (OutFile, 'InFile.txt');
  16.   ReWrite (OutFile);
  17.   Randomize;
  18.   For Index1 := 1 to 100 do begin
  19.     For Index2 := 1 to (Random (5) + 1) do
  20.       Write (OutFile, 'These are some very long Text Strings that'
  21.         + ' are written to the File InFile.txt in order to test' +
  22.         ' the capability of reading verylong Text lines. Lines' +
  23.         ' that even exceed Turbo Pascal''s limit of 255' +
  24.         ' caracters per String');
  25.     Writeln (OutFile, 'EOLN');
  26.   end;
  27.   Close (OutFile);
  28.  
  29.       { Now re-open it and copy InFile.txt to OutFile.txt   }
  30.   Assign (InFile, 'InFile.txt');
  31.   Assign (OutFile, 'OutFile.txt');
  32.   Reset (InFile);
  33.   ReWrite (OutFile);
  34.  
  35.   While not Eof (InFile) do begin
  36.     While not Eoln (InFile) do begin
  37.  
  38.       { While we are not at enf-of-line, read 255           }
  39.       { caracters notice we use READ instead of READLN      }
  40.       { because the latter would skip to the next line even }
  41.       { if data was still left on this line.}
  42.  
  43.       Read (InFile, LinePart);
  44.       Result := Ioresult;
  45.       Writeln ('Result was ', Result);
  46.       Write (OutFile, LinePart);
  47.     end;
  48.  
  49.       { We have reached end-of-Line so do a readln to skip  }
  50.       { to the start of the next line.}
  51.  
  52.     Readln (InFile);
  53.  
  54.       { Also Writeln to output File so it to, skips to the  }
  55.       { next line.                                          }
  56.  
  57.     Writeln (OutFile);
  58.  
  59.   end;
  60.  
  61.       { Close both Files                                    }
  62.  
  63.   Close (OutFile);
  64.   Close (InFile);
  65. end.
  66.  
  67.